#coding=utf-8
__author__ = 'liubin'

import os
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.admin import Admin
from flask.ext.restful import Api

#初始化Flask
app = Flask(__name__)
app.config.from_pyfile('config.py')

#初始化Sqlalchemy
db = SQLAlchemy(app)

#加载Models
from project.models import *

#加载Admin
admin_view = Admin(app, name=u'订单宝后台管理')

#加载restful
api_view = Api(app)

#加载Views
from project.views import *


#生成上传文件夹
try:
    os.mkdir(app.config['UPLOAD_PATH'])
except OSError:
    pass

def init_db():
    db.drop_all()
    db.create_all()